import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hixing_app/const/gaps.dart';
import 'package:hixing_app/utils/export_utils.dart';
import 'package:hixing_app/widgets/grey_border_input/grey_border_input.dart';
import 'package:hixing_app/widgets/menu_item.dart';
import 'package:hixing_app/widgets/search_input/search_input.dart';

class TestPublicArticle extends StatefulWidget {
  @override
  _TestPublicArticleState createState() => _TestPublicArticleState();
}

class _TestPublicArticleState extends State<TestPublicArticle> {
  TextEditingController _articleCtrl = TextEditingController();

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    _articleCtrl.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.white,
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Gaps.getVGap(ScreenUI.topSafeHeight),
              Padding(
                padding: EdgeInsets.symmetric(horizontal: 10),
                child: Row(
                  children: [
                    GestureDetector(
                      onTap: () {
                        Get.back();
                      },
                      child: Icon(Icons.arrow_back),
                    ),
                    Gaps.hGap10,
                    Expanded(
                      child: Container(
                        decoration: BoxDecoration(
                            color: Color(0xFFF1F1F1),
                            borderRadius: BorderRadius.circular(4)),
                        padding:
                            EdgeInsets.symmetric(horizontal: 6, vertical: 8),
                        child: Row(
                          children: [
                            Text(
                              "发布优质贴可以获得更多",
                              style: TextStyle(
                                color: Colors.black,
                                fontSize: 12,
                              ),
                            ),
                            Text(
                              "曝光机会 >",
                              style: TextStyle(fontSize: 12, color: Colors.red),
                            ),
                          ],
                        ),
                      ),
                    ),
                    Gaps.hGap10,
                    ElevatedButton(
                      style: ButtonStyle(
                        backgroundColor:
                            MaterialStateProperty.all(Colors.orange),
                        shape:
                            MaterialStateProperty.all<RoundedRectangleBorder>(
                          RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(4.0),
                          ),
                        ),
                      ),
                      onPressed: () {},
                      child: Text(
                        "发帖",
                        style: TextStyle(fontSize: 15, color: Colors.white),
                      ),
                    )
                  ],
                ),
              ),
              Gaps.vGap10,
              Container(
                child: GreyBorderTextField(
                  textController: _articleCtrl,
                  maxLines: 6,
                  hintText: "说点什么吧...",
                  borderColor: Colors.transparent,
                  onChanged: (val) {},
                ),
              ),
              Container(
                margin: EdgeInsets.all(10),
                width: 100,
                height: 100,
                decoration: BoxDecoration(
                    color: Color(0xFFf1f1f1),
                    borderRadius: BorderRadius.circular(4)),
                child: Icon(Icons.add),
              ),
              SettingMenuItem(
                label: "工程文件",
                btmBorder: false,
              ),
              SettingMenuItem(
                label: "材质",
                btmBorder: false,
              ),
              SettingMenuItem(
                label: "机型",
                btmBorder: false,
              ),
              SettingMenuItem(
                label: "打印尺寸",
                btmBorder: false,
              ),
              SettingMenuItem(
                label: "分辨率",
                btmBorder: false,
              ),
              SettingMenuItem(
                label: "雕刻时间",
                btmBorder: false,
              ),
              _buildStep(),
            ],
          ),
        ));
  }

  _buildStep() {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 16.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            "操作步骤",
            style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
          ),
          Gaps.vGap10,
          Padding(
            padding: EdgeInsets.symmetric(horizontal: 10),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  "1. 准备好雕刻机，防护罩，皮革",
                  style: TextStyle(fontSize: 14, color: Colors.grey),
                ),
                Text(
                  "2.调好参数，设计图片，雕刻过程中",
                  style: TextStyle(fontSize: 14, color: Colors.grey),
                ),
                Text(
                  "3.完成展示或者注意事项",
                  style: TextStyle(fontSize: 14, color: Colors.grey),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}
